##
##  $Header: /pub/cvsroot/mydns/doc/texinfo/Makefile.am,v 1.9 2003/03/15 01:09:33 bboy Exp $
##

TEXIFILES	=	configuration.texi \
					database.texi \
					fdl.texi \
					installation.texi \
					introduction.texi \
					mydns.texi \
					references.texi \
					server.texi \
					title.texi \
					troubleshooting.texi \
					utilities.texi

EXTRA_DIST	=	$(TEXIFILES)

instdir		=	$(DESTDIR)$(infodir)
RUN			=	$(SHELL) @top_srcdir@/missing --run
RUNMAKEINFO	=	$(SHELL) @top_srcdir@/makeinfo
TEXIVARS		=	@top_srcdir@/doc/texinfo/variables.texi
TEXIFILE		=	@PACKAGE@.texi
INFOFILE		=	@PACKAGE@.info
DVIFILE		=	@PACKAGE@.dvi
TEMPEXT		=	aux cp cps dvi fn ky log pg toc tp vr vrs

all: info

sedfile:
	if ! test -f @SEDFILE@; then \
	   cd @top_srcdir@ && $(MAKE) sedfile; \
	fi

variables.texi:
	@if `test -f $(TEXIVARS)`; then rm -f $(TEXIVARS); fi
	@echo "@set MYDNSCONF @MYDNS_CONF@" >> $(TEXIVARS)
	@echo "@set PKGDATE @PACKAGE_DATE@" >> $(TEXIVARS)
	@echo "@set PKGNAME @PACKAGE_NAME@" >> $(TEXIVARS)
	@echo "@set PKGVERSION @PACKAGE_VERSION@" >> $(TEXIVARS)
	@echo "@set PKGSTRING @PACKAGE_STRING@" >> $(TEXIVARS)
	@echo "@set PKGAUTHOR @PACKAGE_AUTHOR@" >> $(TEXIVARS)
	@echo "@set PKGBUGREPORT @PACKAGE_BUGREPORT@" >> $(TEXIVARS)
	@echo "@set PKGHOMEPAGE @PACKAGE_HOMEPAGE@" >> $(TEXIVARS)
	@echo "@set PKGCOPYRIGHT @PACKAGE_COPYRIGHT@" >> $(TEXIVARS)

info: sedfile variables.texi
	$(RUNMAKEINFO) -o @DOCDIR@/$(INFOFILE) $(TEXIFILE)

pdf: pdfcreate cleantemp

pdfcreate: sedfile variables.texi
	$(RUN) texi2dvi --batch --pdf $(TEXIFILE)
	if test -f @PACKAGE@.pdf; then mv -f @PACKAGE@.pdf @DOCDIR@/@PACKAGE@.pdf; fi

ps: pscreate cleantemp

pscreate: sedfile variables.texi
	$(RUN) texi2dvi -q $(TEXIFILE)
	if test -f $(DVIFILE); then \
	   $(RUN) dvips -q -t letter $(DVIFILE) -o @DOCDIR@/@PACKAGE@_letter.ps; \
	   $(RUN) dvips -q -t a4 $(DVIFILE) -o @DOCDIR@/@PACKAGE@_a4.ps; \
	fi

cleantemp:
	for ext in $(TEMPEXT); do $(RM) @PACKAGE@.$$ext; done

clean: restore cleantemp
	$(RM) $(TEXIVARS)
	$(RM) @DOCDIR@/@PACKAGE@.info
	$(RM) @PACKAGE@.dvi
	$(RM) @PACKAGE@_letter.ps @DOCDIR@/@PACKAGE@_letter.ps
	$(RM) @PACKAGE@_a4.ps @DOCDIR@/@PACKAGE@_a4.ps
	$(RM) @PACKAGE@.pdf @DOCDIR@/@PACKAGE@.pdf

install: all
	@if test -f @DOCDIR@/@PACKAGE@.info; then \
	   if ! test -d $(instdir); then \
	      $(INSTALL) -d $(instdir); \
	   fi; \
	   $(INSTALL_DATA) @DOCDIR@/@PACKAGE@.info $(instdir)/@PACKAGE@.info; \
	   echo && echo "***"; \
	   echo "***  @PACKAGE@.info -> $(instdir)/@PACKAGE@.info"; \
	   echo "***" && echo; \
	fi

restore:
	@for f in $(TEXIFILES); do \
	   if test -f $$f.en; then \
	      if test -z "$$header"; then \
	         echo; echo "***"; echo "***  Restoring original Texinfo documentation:"; echo "***"; \
	         header="Y"; \
	      fi; \
	      $(RM) $$f; \
	      mv $$f.en $$f; \
		   echo "***  - $$f"; \
	   fi; \
	done; if ! test -z "$$header"; then echo "***"; echo; fi

.PHONY: all sedfile variables.texi info pdf pdfcreate ps pscreate cleantemp clean install restore

## vi:set ts=3:
